﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using YArchitech.DataModel;
using YArchitech.LIB;
using HYRevitCode.RevitTopologySuite;
using QuickModel.Basic;
using QuickModel.CommonTrans;
using QuickModel.InteractiveOperation;
using QuickModel.InteractiveOperation.CmdTestInteractiveOperation;
using QuickModel.Models;
using Transfer.Utils;

namespace QuickModel.LastFastModeling
{
	public class BussinessCommon
	{
		public static void GetTvwDatas(TreeView tvw, string equipName, List<Family> familys)
		{
			tvw.Nodes.Clear();
			bool flag = familys == null || familys.Count <= 0;
			if (!flag)
			{
				TreeNode treeNode = new TreeNode();
				treeNode.Text = equipName;
				treeNode.Tag = null;
				foreach (Family family in familys)
				{
					TreeNode treeNode2 = new TreeNode();
					treeNode2.Text = family.Name;
					treeNode2.Tag = null;
					List<FamilySymbol> familySymbols = RevitCommonFunctions.GetFamilySymbols(family);
					bool flag2 = familySymbols != null && familySymbols.Count > 0;
					if (flag2)
					{
						foreach (FamilySymbol familySymbol in familySymbols)
						{
							TreeNode treeNode3 = new TreeNode();
							treeNode3.Text = familySymbol.Name;
							treeNode3.Tag = familySymbol;
							treeNode2.Nodes.Add(treeNode3);
						}
					}
					treeNode.Nodes.Add(treeNode2);
				}
				tvw.Nodes.Add(treeNode);
				tvw.ExpandAll();
			}
		}

		public static void GetHYFamilys(ListView m_lvwFamilys, string equipType)
		{
			m_lvwFamilys.Items.Clear();
			bool flag = string.IsNullOrEmpty(equipType);
			if (!flag)
			{
				SpaceFamilyDataReader spaceFamilyDataReader = new SpaceFamilyDataReader();
				List<ListItem> list = new List<ListItem>();
				list = spaceFamilyDataReader.GetAllNameAndImage2D(equipType);
				bool flag2 = list == null || list.Count <= 0;
				if (!flag2)
				{
					List<string> list2 = new List<string>();
					foreach (ListItem listItem in list)
					{
						string value = listItem.Value;
						bool flag3 = !File.Exists(listItem.Value) || list2.Contains(value);
						if (!flag3)
						{
							string text = Guid.NewGuid().ToString();
							m_lvwFamilys.LargeImageList.Images.Add(text, Image.FromFile(value));
							ListViewItem listViewItem = new ListViewItem();
							listViewItem.Text = listItem.Name;
							listViewItem.Tag = listItem;
							listViewItem.ImageKey = text;
							m_lvwFamilys.Items.Add(listViewItem);
							list2.Add(value);
						}
					}
					WindowsApi.SetListViewSpacing(m_lvwFamilys, m_lvwFamilys.LargeImageList.ImageSize.Width + 30, m_lvwFamilys.LargeImageList.ImageSize.Height + 10);
				}
			}
		}

		public static List<string> GetSymbolsFromDB(ListItem item, string equipTable)
		{
			bool flag = item == null;
			List<string> result;
			if (flag)
			{
				result = new List<string>();
			}
			else
			{
				List<string> list = new List<string>();
				SpaceFamilyDataReader spaceFamilyDataReader = new SpaceFamilyDataReader();
				List<ListItem> infoById = spaceFamilyDataReader.GetInfoById(equipTable, int.Parse(item.Tag.ToString()));
				bool flag2 = infoById.Count > 0;
				if (flag2)
				{
					foreach (ListItem listItem in infoById)
					{
						bool flag3 = listItem == null;
						if (!flag3)
						{
							bool flag4 = listItem.Name == "FamilySymbol";
							if (flag4)
							{
								list = BussinessCommon.GetSymbolNamesByStr(listItem.Value);
								break;
							}
						}
					}
				}
				result = list;
			}
			return result;
		}

		public static List<string> GetSymbolNamesByStr(string value)
		{
			List<string> list = new List<string>();
			string[] array = value.Split(new char[]
			{
				';',
				',',
				'，'
			});
			foreach (string text in array)
			{
				bool flag = !string.IsNullOrEmpty(text) && text.Trim() != "";
				if (flag)
				{
					list.Add(text);
				}
			}
			return list;
		}

		public static void LoadComboBoxDatas(System.Windows.Forms.ComboBox cmb, List<string> datas)
		{
			bool flag = cmb != null && datas != null && datas.Count > 0;
			if (flag)
			{
				cmb.Items.Clear();
				foreach (string item in datas)
				{
					cmb.Items.Add(item);
				}
			}
		}

		public static void SetComboBoxDropDownWidth(System.Windows.Forms.ComboBox comboBox1)
		{
			bool flag = comboBox1 == null;
			if (!flag)
			{
				try
				{
					int num = 0;
					Graphics graphics = comboBox1.CreateGraphics();
					for (int i = 0; i < comboBox1.Items.Count; i++)
					{
						string text = comboBox1.Items[i].ToString();
						bool flag2 = string.IsNullOrEmpty(text);
						if (!flag2)
						{
							SizeF sizeF = graphics.MeasureString(text, comboBox1.Font);
							bool flag3 = num < (int)sizeF.Width;
							if (flag3)
							{
								num = (int)sizeF.Width;
							}
						}
					}
					comboBox1.DropDownWidth = comboBox1.Width;
					bool flag4 = comboBox1.DropDownWidth < num;
					if (flag4)
					{
						comboBox1.DropDownWidth = num;
					}
				}
				catch
				{
				}
			}
		}

		public static List<string> GetListFromString(string value)
		{
			bool flag = string.IsNullOrEmpty(value);
			List<string> result;
			if (flag)
			{
				result = new List<string>();
			}
			else
			{
				char[] separator = new char[]
				{
					',',
					'，'
				};
				result = value.Split(separator).ToList<string>();
			}
			return result;
		}

		public static void ClearListViewSelectState(ListView lvw)
		{
			bool flag = lvw != null && lvw.SelectedItems != null && lvw.SelectedItems.Count > 0;
			if (flag)
			{
				foreach (object obj in lvw.SelectedItems)
				{
					ListViewItem listViewItem = (ListViewItem)obj;
					listViewItem.Selected = false;
				}
			}
		}

		public static string GetEquipType(QuickModelingPara paras)
		{
			bool flag = paras == null || string.IsNullOrEmpty(paras.SpecialtyName) || paras.SelectedEquipData == null;
			string result;
			if (flag)
			{
				result = "";
			}
			else
			{
				result = paras.SpecialtyName + "@" + paras.SelectedEquipData.Name;
			}
			return result;
		}

		public static string GetResultInfo(DwgEntitiesSelection dwgEntitiesSelection, out bool isNeedBreakCommand)
		{
			isNeedBreakCommand = false;
			string text = "未获得图块！命令必须结束！";
			bool flag = dwgEntitiesSelection == null;
			string result;
			if (flag)
			{
				isNeedBreakCommand = true;
				result = text;
			}
			else
			{
				bool flag2 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eUnitError;
				if (flag2)
				{
					result = "链接图纸的导入单位必须是毫米！";
				}
				else
				{
					bool flag3 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eDataError;
					if (flag3)
					{
						result = "所选图元数据不正确！";
					}
					else
					{
						bool flag4 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eDwgPathError;
						if (flag4)
						{
							result = "链接图纸的路径不正确！";
						}
						else
						{
							bool flag5 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eNotGetBlock;
							if (flag5)
							{
								result = "未能获取到块参照！";
							}
							else
							{
								bool flag6 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eNotLinkDwg;
								if (flag6)
								{
									result = "仅支持链接的dwg图纸！";
								}
								else
								{
									bool flag7 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eNotAnalysisDwg;
									if (flag7)
									{
										result = "未能解析dwg图纸，请使用CAD修复图纸、降低图纸版本！";
									}
									else
									{
										bool flag8 = dwgEntitiesSelection.Result == DwgEntitiesSelectionResult.eOtherError;
										if (flag8)
										{
											isNeedBreakCommand = true;
											result = "执行命令发生错误！命令必须结束！";
										}
										else
										{
											isNeedBreakCommand = true;
											result = text;
										}
									}
								}
							}
						}
					}
				}
			}
			return result;
		}

		public static XYZ GetBlockActualLocation(PointPosBlockInfo blockInfo)
		{
			bool flag = blockInfo == null;
			XYZ result;
			if (flag)
			{
				result = null;
			}
			else
			{
				List<XYZ> actualBox = blockInfo.ActualBox;
				bool flag2 = actualBox == null || actualBox.Count != 4;
				if (flag2)
				{
					result = null;
				}
				else
				{
					XYZ xyz = new XYZ(actualBox[0].X, actualBox[0].Y, 0.0);
					XYZ xyz2 = new XYZ(actualBox[3].X, actualBox[3].Y, 0.0);
					result = (xyz + xyz2) / 2.0;
				}
			}
			return result;
		}

		public static XYZ GetBlockFaceDirection(PointPosBlockInfo blockInfo)
		{
			bool flag = blockInfo == null;
			XYZ result;
			if (flag)
			{
				result = null;
			}
			else
			{
				List<XYZ> actualBox = blockInfo.ActualBox;
				bool flag2 = actualBox == null || actualBox.Count != 4;
				if (flag2)
				{
					result = null;
				}
				else
				{
					XYZ xyz = new XYZ(actualBox[1].X, actualBox[1].Y, 0.0);
					XYZ xyz2 = new XYZ(actualBox[0].X, actualBox[0].Y, 0.0);
					result = (xyz - xyz2).Normalize();
				}
			}
			return result;
		}

		public static bool GetBlockCenter(PointPosBlockInfo blockInfo, out XYZ center)
		{
			center = null;
			List<XYZ> actualBox = blockInfo.ActualBox;
			bool flag = actualBox == null || actualBox.Count != 4;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XYZ xyz = new XYZ(actualBox[0].X, actualBox[0].Y, 0.0);
				XYZ xyz2 = new XYZ(actualBox[2].X, actualBox[2].Y, 0.0);
				center = (xyz + xyz2) / 2.0;
				result = true;
			}
			return result;
		}

		public static bool GetBlockWidth(PointPosBlockInfo blockInfo, out double width)
		{
			width = 0.0;
			List<XYZ> actualBox = blockInfo.ActualBox;
			bool flag = actualBox == null || actualBox.Count != 4;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XYZ xyz = new XYZ(actualBox[0].X, actualBox[0].Y, 0.0);
				XYZ xyz2 = new XYZ(actualBox[3].X, actualBox[3].Y, 0.0);
				width = xyz.DistanceTo(xyz2);
				result = (width > 0.0);
			}
			return result;
		}

		public static void CheckBlockIsMirrored(XYZ scale, out bool isMirroredX, out bool isMirroredY)
		{
			isMirroredX = false;
			isMirroredY = false;
			bool flag = BussinessCommon.CheckValue(scale.X) < 0;
			if (flag)
			{
				isMirroredX = true;
			}
			bool flag2 = BussinessCommon.CheckValue(scale.Y) < 0;
			if (flag2)
			{
				isMirroredY = true;
			}
		}

		public static int CheckValue(double value)
		{
			bool flag = Geometry.IsEqual(value, 0.0, 1E-05);
			int result;
			if (flag)
			{
				result = 0;
			}
			else
			{
				bool flag2 = value > 0.0;
				if (flag2)
				{
					result = 1;
				}
				else
				{
					result = -1;
				}
			}
			return result;
		}

		public static XYZ GetPointFromCurve(Curve c)
		{
			bool flag = c is Line;
			XYZ result;
			if (flag)
			{
				result = c.GetEndPoint(0);
			}
			else
			{
				bool flag2 = c is Arc;
				if (flag2)
				{
					Arc arc = c as Arc;
					List<XYZ> list = arc.Tessellate().ToList<XYZ>();
					bool flag3 = list != null && list.Count > 0;
					if (flag3)
					{
						return list[0];
					}
				}
				result = null;
			}
			return result;
		}

		public static XYZ GetVectorFromCurve(Curve c)
		{
			bool flag = c == null;
			XYZ result;
			if (flag)
			{
				result = null;
			}
			else
			{
				XYZ xyz = c.GetEndPoint(0);
				XYZ xyz2 = c.GetEndPoint(1);
				xyz = new XYZ(xyz.X, xyz.Y, 0.0);
				xyz2 = new XYZ(xyz2.X, xyz2.Y, 0.0);
				XYZ xyz3 = (xyz + xyz2) / 2.0;
				XYZ xyz4 = (xyz2 - xyz).Normalize();
				result = xyz4;
			}
			return result;
		}

		public static Line GetVerticalLineFromCurve(Curve c)
		{
			bool flag = c == null;
			Line result;
			if (flag)
			{
				result = null;
			}
			else
			{
				XYZ xyz = c.GetEndPoint(0);
				XYZ xyz2 = c.GetEndPoint(1);
				xyz = new XYZ(xyz.X, xyz.Y, 0.0);
				xyz2 = new XYZ(xyz2.X, xyz2.Y, 0.0);
				bool flag2 = xyz.IsAlmostEqualTo(xyz2);
				if (flag2)
				{
					result = null;
				}
				else
				{
					XYZ xyz3 = (xyz + xyz2) / 2.0;
					XYZ xyz4 = (xyz2 - xyz).Normalize();
					XYZ xyz5 = xyz4.CrossProduct(XYZ.BasisZ);
					XYZ xyz6 = xyz3 + xyz5;
					result = Line.CreateBound(xyz3, xyz6);
				}
			}
			return result;
		}

		public static Line GetUnBoundVerticalLineFromCurve(Curve c)
		{
			bool flag = c == null;
			Line result;
			if (flag)
			{
				result = null;
			}
			else
			{
				XYZ xyz = c.GetEndPoint(0);
				XYZ xyz2 = c.GetEndPoint(1);
				xyz = new XYZ(xyz.X, xyz.Y, 0.0);
				xyz2 = new XYZ(xyz2.X, xyz2.Y, 0.0);
				bool flag2 = xyz.IsAlmostEqualTo(xyz2);
				if (flag2)
				{
					result = null;
				}
				else
				{
					XYZ xyz3 = (xyz + xyz2) / 2.0;
					XYZ xyz4 = (xyz2 - xyz).Normalize();
					XYZ xyz5 = xyz4.CrossProduct(XYZ.BasisZ);
					result = Line.CreateUnbound(xyz3, xyz5);
				}
			}
			return result;
		}

		public static void SeparateCurves(List<Curve> curves, out List<Curve> lineCurves, out List<Curve> arcCurves)
		{
			lineCurves = new List<Curve>();
			arcCurves = new List<Curve>();
			bool flag = curves == null || curves.Count <= 0;
			if (!flag)
			{
				foreach (Curve curve in curves)
				{
					bool flag2 = curve == null;
					if (!flag2)
					{
						bool flag3 = curve is Line;
						if (flag3)
						{
							lineCurves.Add(curve);
						}
						else
						{
							arcCurves.Add(curve);
						}
					}
				}
			}
		}

		public static void SeparateCloseCurves(List<Curve> curves, out List<Curve> notCloseCurves, out List<Curve> closeCurves)
		{
			notCloseCurves = new List<Curve>();
			closeCurves = new List<Curve>();
			bool flag = curves == null || curves.Count <= 0;
			if (!flag)
			{
				foreach (Curve curve in curves)
				{
					bool flag2 = curve == null;
					if (!flag2)
					{
						Arc arc = curve as Arc;
						bool flag3 = arc != null && !arc.IsBound && arc.IsCyclic;
						if (flag3)
						{
							closeCurves.Add(arc);
						}
						else
						{
							Ellipse ellipse = curve as Ellipse;
							bool flag4 = ellipse != null && !ellipse.IsBound && ellipse.IsCyclic;
							if (flag4)
							{
								closeCurves.Add(ellipse);
							}
							else
							{
								notCloseCurves.Add(curve);
							}
						}
					}
				}
			}
		}

		public static bool GetMaxBoundCurves(List<Curve> curves, bool ifSplitInput, out List<Curve> maxBoundCurves)
		{
			maxBoundCurves = new List<Curve>();
			bool flag = curves.IsEmpty<Curve>();
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				try
				{
					List<Curve> curves2 = null;
					List<Curve> closeCurves = null;
					BussinessCommon.SeparateCloseCurves(curves, out curves2, out closeCurves);
					Curve item = null;
					double num = 0.0;
					List<Curve> list = new List<Curve>();
					bool maxAreaCloseCurve = BussinessCommon.GetMaxAreaCloseCurve(closeCurves, out item, out num);
					bool flag2 = maxAreaCloseCurve;
					if (flag2)
					{
						list.Add(item);
					}
					List<Curve> list2 = null;
					double num2 = 0.0;
					bool maxAreaBoundCurves = BussinessCommon.GetMaxAreaBoundCurves(curves2, ifSplitInput, out list2, out num2);
					bool flag3 = !maxAreaCloseCurve && !maxAreaBoundCurves;
					if (flag3)
					{
						return false;
					}
					bool flag4 = num2 > num;
					if (flag4)
					{
						maxBoundCurves = list2;
					}
					else
					{
						maxBoundCurves = list;
					}
					return true;
				}
				catch (Exception ex)
				{
				}
				result = false;
			}
			return result;
		}

		public static bool GetMaxAreaBoundCurves(List<Curve> curves, bool ifSplitInput, out List<Curve> maxBoundCurves, out double maxArea)
		{
			maxBoundCurves = new List<Curve>();
			maxArea = 0.0;
			bool flag = curves.IsEmpty<Curve>();
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				try
				{
					RevitPolygonFinder revitPolygonFinder = new RevitPolygonFinder();
					List<RevitPolygonDataBean> list = null;
					List<RevitPolygonDataBean> source = null;
					bool flag2 = !revitPolygonFinder.TryGetPolygon(curves, out list, out source, ifSplitInput, 3, false);
					if (flag2)
					{
						return false;
					}
					List<RevitPolygonDataBean> list2 = (from a in source
					where a != null && a.Area != null
					select a).ToList<RevitPolygonDataBean>();
					bool flag3 = list2 == null || list2.Count <= 0;
					if (flag3)
					{
						return false;
					}
					List<RevitPolygonDataBean> list3 = (from a in list2
					orderby a.Area descending
					select a).ToList<RevitPolygonDataBean>();
					foreach (RevitPolygonDataBean revitPolygonDataBean in list3)
					{
						List<Curve> curvesFromRevitPolygonDataBean = BussinessCommon.GetCurvesFromRevitPolygonDataBean(revitPolygonDataBean);
						bool flag4 = !curvesFromRevitPolygonDataBean.IsEmpty<Curve>() && revitPolygonDataBean.Area != null;
						if (flag4)
						{
							maxArea = revitPolygonDataBean.Area.Value;
							maxBoundCurves = curvesFromRevitPolygonDataBean;
							return true;
						}
					}
				}
				catch (Exception ex)
				{
				}
				result = false;
			}
			return result;
		}

		public static bool GetMaxAreaCloseCurve(List<Curve> closeCurves, out Curve maxCurve, out double area)
		{
			maxCurve = null;
			area = 0.0;
			bool flag = closeCurves.IsEmpty<Curve>();
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				double num = 0.0;
				foreach (Curve curve in closeCurves)
				{
					Arc arc = curve as Arc;
					bool flag2 = arc == null;
					if (!flag2)
					{
						bool flag3 = arc.Radius > num;
						if (flag3)
						{
							num = arc.Radius;
							maxCurve = curve;
						}
					}
				}
				area = Math.PI * num * num;
				result = (maxCurve == null);
			}
			return result;
		}

		public static List<Curve> GetCurvesFromRevitPolygonDataBean(RevitPolygonDataBean data)
		{
			bool flag = data == null;
			List<Curve> result;
			if (flag)
			{
				result = new List<Curve>();
			}
			else
			{
				List<Curve> list = new List<Curve>();
				foreach (Curve item in data.ShellCurveLoop)
				{
					list.Add(item);
				}
				result = list;
			}
			return result;
		}

		public static List<Curve> CreateTransform(double dMultiple, List<Curve> lstLstCv)
		{
			bool flag = lstLstCv.IsEmpty<Curve>();
			List<Curve> result;
			if (flag)
			{
				result = new List<Curve>();
			}
			else
			{
				List<Curve> list = new List<Curve>();
				Transform identity = Transform.Identity;
				foreach (Curve cv in lstLstCv)
				{
					Curve curve = BussinessCommon.CreateTransform(dMultiple, cv);
					bool flag2 = curve != null;
					if (flag2)
					{
						list.Add(curve);
					}
				}
				result = list;
			}
			return result;
		}

		public static Curve CreateTransform(double dMultiple, Curve cv)
		{
			bool flag = cv == null;
			Curve result;
			if (flag)
			{
				result = null;
			}
			else
			{
				result = cv.CreateTransformed(Transform.Identity.ScaleBasis(dMultiple));
			}
			return result;
		}

		public static void MirrorElement(Autodesk.Revit.DB.Document doc, Element createdFi, XYZ location, int mirrorType)
		{
			List<ElementId> list = new List<ElementId>();
			bool flag = ElementTransformUtils.CanMirrorElement(doc, createdFi.Id);
			if (flag)
			{
				list.Add(createdFi.Id);
			}
			bool flag2 = list != null && list.Count > 0;
			if (flag2)
			{
				XYZ normal = (mirrorType == -1) ? XYZ.BasisX : XYZ.BasisY;
				Plane plane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(normal, location);
				ElementTransformUtils.MirrorElements(doc, list, plane, false);
				doc.Regenerate();
			}
		}

		public static void RotateElement(Autodesk.Revit.DB.Document document, Element elementToMirror, double angle)
		{
			LocationPoint locationPoint = elementToMirror.Location as LocationPoint;
			bool flag = locationPoint == null;
			if (!flag)
			{
				XYZ point = locationPoint.Point;
				Line line = Line.CreateBound(point, new XYZ(point.X, point.Y, point.Z + 1.0));
				ElementTransformUtils.RotateElement(document, elementToMirror.Id, line, angle);
			}
		}

		public static void RotateElement(Autodesk.Revit.DB.Document document, Element elementToMirror, XYZ location, double angle)
		{
			Line line = Line.CreateBound(location, new XYZ(location.X, location.Y, location.Z + 1.0));
			ElementTransformUtils.RotateElement(document, elementToMirror.Id, line, angle);
		}

		public static void MoveElement(Autodesk.Revit.DB.Document doc, Element createdFi, XYZ translation)
		{
			ElementTransformUtils.MoveElement(doc, createdFi.Id, translation);
		}

		public static double GetDoubleByText(string text, int decimalDigits)
		{
			bool flag = string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text.Trim());
			double result;
			if (flag)
			{
				result = 0.0;
			}
			else
			{
				double num = 0.0;
				bool flag2 = !double.TryParse(text.Trim(), out num);
				if (flag2)
				{
					result = 0.0;
				}
				else
				{
					double num2 = 0.0;
					bool flag3 = !double.TryParse(num.ToString("F" + decimalDigits.ToString()), out num2);
					if (flag3)
					{
						result = 0.0;
					}
					else
					{
						result = num2;
					}
				}
			}
			return result;
		}

		public static int GetIntByText(string text)
		{
			bool flag = string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text.Trim());
			int result;
			if (flag)
			{
				result = 0;
			}
			else
			{
				double num = 0.0;
				bool flag2 = !double.TryParse(text.Trim(), out num);
				if (flag2)
				{
					result = 0;
				}
				else
				{
					int num2 = 0;
					bool flag3 = !int.TryParse(num.ToString("F0"), out num2);
					if (flag3)
					{
						result = 0;
					}
					else
					{
						result = num2;
					}
				}
			}
			return result;
		}

		public static void TestScaleCurve(Autodesk.Revit.DB.Document doc)
		{
			Transaction transaction = new Transaction(doc, "ss");
			try
			{
				transaction.Start();
				XYZ xyz = new XYZ(1.0, 1.0, 0.0);
				XYZ xyz2 = new XYZ(xyz.X + 2.0, xyz.Y, xyz.Z);
				Curve curve = Line.CreateBound(xyz, xyz2);
				DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, curve);
				Transform identity = Transform.Identity;
				Curve curve2 = curve.CreateTransformed(identity.ScaleBasis(10.0));
				XYZ endPoint = curve2.GetEndPoint(0);
				XYZ endPoint2 = curve2.GetEndPoint(1);
				DetailCurve detailCurve2 = doc.Create.NewDetailCurve(doc.ActiveView, curve2);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
			finally
			{
				bool flag = (int)transaction.GetStatus() == 1;
				if (flag)
				{
					transaction.Commit();
				}
			}
		}

		public static void DrawCurves(Autodesk.Revit.DB.Document doc, List<Curve> curves, double dMultiple)
		{
			List<Curve> list = BussinessCommon.CreateTransform(dMultiple, curves);
			foreach (Curve curCurve in list)
			{
				TestCommon.CreateModelCurve(curCurve, doc, new Autodesk.Revit.DB.Color(0, byte.MaxValue, 0), 1);
			}
		}

		public static void DrawCurves2(Autodesk.Revit.DB.Document doc, List<Curve> curves, double dMultiple)
		{
			List<Curve> list = BussinessCommon.CreateTransform(dMultiple, curves);
			Transaction transaction = new Transaction(doc, "ssss");
			try
			{
				transaction.Start();
				foreach (Curve curCurve in list)
				{
					TestCommon.CreateModelCurve(curCurve, doc, new Autodesk.Revit.DB.Color(byte.MaxValue, 0, 0), 1);
				}
			}
			catch
			{
				transaction.RollBack();
			}
			finally
			{
				bool flag = (int)transaction.GetStatus() == 1;
				if (flag)
				{
					transaction.Commit();
				}
			}
		}

		private void ShowBoundingBoxCurve(Element e)
		{
			bool flag = e == null;
			if (!flag)
			{
				Document document = e.Document;
				BoundingBoxXYZ boundingBoxXYZ = e.get_BoundingBox(document.ActiveView);
				bool flag2 = boundingBoxXYZ == null;
				if (!flag2)
				{
					XYZ xyz = new XYZ(boundingBoxXYZ.Min.X, boundingBoxXYZ.Min.Y, 0.0);
					XYZ xyz2 = new XYZ(boundingBoxXYZ.Min.X, boundingBoxXYZ.Max.Y, 0.0);
					XYZ xyz3 = new XYZ(boundingBoxXYZ.Max.X, boundingBoxXYZ.Max.Y, 0.0);
					XYZ xyz4 = new XYZ(boundingBoxXYZ.Max.X, boundingBoxXYZ.Min.Y, 0.0);
					foreach (Curve curCurve in new List<Curve>
					{
						Line.CreateBound(xyz, xyz2),
						Line.CreateBound(xyz2, xyz3),
						Line.CreateBound(xyz3, xyz4),
						Line.CreateBound(xyz4, xyz)
					})
					{
						TestCommon.CreateModelCurve(curCurve, document, new Autodesk.Revit.DB.Color(0, byte.MaxValue, 0), 1);
					}
				}
			}
		}
	}
}
